/**
 * 
 */
package com.sys.console.monitor;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Component;

import com.sys.console.mapper.SysUserLoginLogsMapper;
import com.sys.console.pojo.SysUserLoginLogs;
import com.sys.console.pojo.Sys_User;
import com.sys.object.common.context.ServiceInitContainer;
import com.sys.object.common.utils.IpUtils;

/**
 * @author JDYG-001
 *
 */
@Component
public class LoginLogs {

	public static void monSaveLoginInfo(final Sys_User user,final int type ,final HttpServletRequest request){
		new Thread(new Runnable() {
			@Override
			public void run() {
				// TODO Auto-generated method stub
				SysUserLoginLogsMapper mapper = (SysUserLoginLogsMapper) ServiceInitContainer.mapperMap.get("sysUserLoginLogsMapper");
				System.out.println(mapper+"=====LoginLogs=============monSaveLoginInfo======="+user.getUid());
				
				SysUserLoginLogs logs = new SysUserLoginLogs();
				logs.setUid(user.getUid());
				logs.setLogintime(new Date());
				logs.setLogintype(type);
				logs.setLoginip(IpUtils.getIpAddr(request));
				mapper.insert(logs);
			}
		}).start();
	}
}
